package com.hucheng.seckill;

import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
import com.hucheng.common.config.aspect.DynamicDataSourceAspect;
import com.hucheng.common.config.db.DynamicDataSourceRegister;
import com.hucheng.seckill.service.SeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @Author: 凉白开不加冰
 * @Date: 2019-06-17 14:31
 * @Description: 秒杀服务启动类
 **/
@SpringBootApplication
@EnableDubboConfiguration
@EnableTransactionManagement
@Import(value = {DynamicDataSourceRegister.class, DynamicDataSourceAspect.class})
public class DubboSeckillProviderApplication implements CommandLineRunner {

    @Autowired
    private SeckillGoodsService seckillGoodsService;

    public static void main(String[] args) {
        SpringApplication.run(DubboSeckillProviderApplication.class, args);
    }

    @Override
    public void run(String... strings) throws Exception {
        //初始化秒杀商品信息
        seckillGoodsService.initSeckillGoods();
    }
}
